package com.code.AZPlan.service.listener;

import com.code.AZPlan.api.AZPlanStaticIncomeService;
import com.code.AZPlan.service.mapper.AZPlanStaticIncomeMapper;
import com.code.commons.constants.ServerConstants;
import com.code.commons.util.CollectionUtil;
import com.code.commons.util.StringUtil;
import com.code.user.model.po.UserRecommender;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import xwc.usertree.Account;
import xwc.usertree.AccountTree;
import xwc.usertree.exceptions.AccountNotFoundException;
import xwc.usertree.exceptions.NewAccountException;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Spring Boot 启动时执行加载资源/执行操作
 *
 * @author tangyifei
 * @since 2020年1月16日11:24:08
 */
@Order(value = 2) // @Order的值来控制启动的顺序，值越小表示越先执行
@Component
@Slf4j
public class CommandLineRunnerListenerImpl implements CommandLineRunner {

    @Resource
    private AZPlanStaticIncomeService azPlanStaticIncomeService;

    @Override
    public void run(String... args) {
        try {
            azPlanStaticIncomeService.reloadAccountTree();
        } catch (Exception e) {
            log.error("初始化推荐树报错", e);
        }

    }


}
